package com.wilmer.user.controller;

import com.wilmer.common.annotation.Anonymous;
import com.wilmer.common.constant.Constants;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.user.domain.WeChatLogin;
import com.wilmer.user.service.WeChatLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 * @author hans
 */
@Api(tags = "小程序手机号快速登录接口")
@RequestMapping("/wechat")
@RestController
public class WeChatLoginController extends BaseController {

    @Resource
    WeChatLoginService weChatLoginService;


    @ApiOperation("快速登录登录")
    @Anonymous()
    @PostMapping("/login")
    public AjaxResult WechatLogin(@RequestBody WeChatLogin weChatLogin){

        AjaxResult ajax = AjaxResult.success();

        String token = weChatLoginService.getWechatUser(weChatLogin);


        ajax.put(Constants.TOKEN, token);

        return ajax;
    }

}
